//
//  ShareWarpper.h
//  YuiKe
//
//  Created by yuike5 yuike5 on 11-10-31.
//  Copyright 2011年 yuike. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <MessageUI/MessageUI.h>
#import "CommentController.h"
#import "WeiboHeader.h"
#import "WeiboNode.h"
#import "MyActionSheet.h"
#import "YWeiboDef.h"

@interface EmailAttachment : NSObject {
    NSData* data;
    NSString* mimeType;
    NSString* fileName;
}
@property (nonatomic, retain) NSData* data;
@property (nonatomic, retain) NSString* mimeType;
@property (nonatomic, retain) NSString* fileName;
@end

@interface WeiboWarperNodex : NSObject {
    NSString* message;
    NSString* cpsUrlReal;
    NSString* cpsUrlShow;
    UIImage* image;
    // default null
    NSString* hideTextHead;
    NSString* hideTextTail;
    NSMutableArray* suggests; // string array
    
    NSString* theNaviTitle; // 分享界面的title
    NSString* theTip; // @那个肯为你买单的TA吧
    
    // for QQ addShare
    NSString* product_title;
    NSString* product_url;
    NSString* product_summary;
    NSString* imageurl;
}
@property (nonatomic, copy) NSString* message;
@property (nonatomic, copy) NSString* cpsUrlReal;
@property (nonatomic, copy) NSString* cpsUrlShow;
@property (nonatomic, retain) UIImage* image;
@property (nonatomic, copy) NSString* hideTextHead;
@property (nonatomic, copy) NSString* hideTextTail;
@property (nonatomic, retain) NSMutableArray* suggests;

@property (nonatomic, copy) NSString* theNaviTitle;
@property (nonatomic, copy) NSString* theTip;
@property (nonatomic, copy) NSString* product_title;
@property (nonatomic, copy) NSString* product_url;
@property (nonatomic, copy) NSString* product_summary;
@property (nonatomic, copy) NSString* imageurl;
@end

@interface EmailWarperNodex : NSObject {
    NSString* title;
    NSString* html;
    NSArray* attachments; // null
}
@property (nonatomic, retain) NSString* title;
@property (nonatomic, retain) NSString* html;
@property (nonatomic, retain) NSArray* attachments;
@end

@interface ImageWarperNodex : NSObject {
    UIImage* coverImage;
    NSArray* images;
}
@property (nonatomic, retain) UIImage* coverImage;
@property (nonatomic, retain) NSArray* images;
@end



@protocol ShareWarpperDelegate <NSObject>
-(WeiboWarperNodex*) shareWarperWeibo:(ShareId)idx;
@optional
-(EmailWarperNodex*) shareWarperEmail:(ShareId)idx;
-(ImageWarperNodex*) shareWarperImage:(ShareId)idx;
-(NSArray*) shareWarperWeiboSuggests:(ShareId)idx; // suggests -- 字符串，一个竖线|分割表示：前面显示，后面为内容。
@end





@interface ShareWarpper : NSObject<UIActionSheetDelegate, MyActionSheetDelegate, MFMailComposeViewControllerDelegate>
{
    UIViewController* vCtrl;
    id<ShareWarpperDelegate> delegate;
    
    int imageSaveCount;
    int imageSaveOkCount, imageSaveFailCount;
    int imageSaveIndex;
    
    ShareId thisidx;
    
    id doneDelegate;
    SEL doneSel;
    
    BOOL useCustomedActionSheet;
    
    NSString* SHARE_SINA_WEIBO;// @"分享到新浪微博"
    NSString* SHARE_EMAIL;// @"用邮件发送"
    NSString* SAVE_IMAGE;//  @"保存当前图片到相册"
    NSString* SAVE_IMAGES;// @"保存当前图集到相册"
    NSString* EMAIL_ACCOUNT_NOT_SETED;//@"邮件帐号未设置"
    // tencent...
    NSString* SHARE_TENCENT_WEIBO;  // 分享到腾讯微博
    NSString* SHARE_TENCENT_SPACE;  // 分享到QQ空间说说
    NSString* SHARE_TENCENT_ALL;    // @"分享到QQ分享";//分享到QQ空间朋友网和腾讯微博
    NSString* SAVE_IMAGE_QQ_SPACE;  // 上传当前图片到QQ空间相册
    NSString* SAVE_IMAGES_QQ_SPACE; // 上传当前图集到QQ空间相册
}

@property (nonatomic, assign) id<ShareWarpperDelegate> delegate;
@property (nonatomic, assign) BOOL useCustomedActionSheet;

@property (nonatomic, copy) NSString* SHARE_SINA_WEIBO;
@property (nonatomic, copy) NSString* SHARE_EMAIL;
@property (nonatomic, copy) NSString* SAVE_IMAGE;
@property (nonatomic, copy) NSString* SAVE_IMAGES;
@property (nonatomic, copy) NSString* EMAIL_ACCOUNT_NOT_SETED;

@property (nonatomic, copy) NSString* SHARE_TENCENT_WEIBO;
@property (nonatomic, copy) NSString* SHARE_TENCENT_SPACE;
@property (nonatomic, copy) NSString* SHARE_TENCENT_ALL;
@property (nonatomic, copy) NSString* SAVE_IMAGE_QQ_SPACE;
@property (nonatomic, copy) NSString* SAVE_IMAGES_QQ_SPACE;



-(void) setDoneDelegate:(id)delegate sel:(SEL)sel; ////-(void) beforeDoneAccountManager;


- (id)init:(UIViewController*)vCtrl_ delegate:(id<ShareWarpperDelegate>)delegate_;


#define SHAREMASK_SAVE_IMAGE     0x001
#define SHAREMASK_EMAIL          0x002
#define SHAREMASK_SINA_WEIBO     0x004
#define SHAREMASK_TENCENT_SHARE  0x008

#define SHAREMASK_ALL            0xfff
#define SHAREMASK_SNS_ALL        (SHAREMASK_EMAIL|SHAREMASK_SINA_WEIBO|SHAREMASK_TENCENT_SHARE)


-(void) shareItemPressedItem:(UIBarButtonItem*) item  idx:(ShareId)idx with:(int)incx;
-(void) shareItemPressedRect:(CGRect)rect view:(UIView*)view  idx:(ShareId)idx with:(int)incx;

-(void) commentItemPressed:(WeiboBase*)weibo node:(WeiboNode*)node 
                  callback:(id<CommentControllerCallback>)callback  idx:(ShareId)idx;


- (void)actionTitle:(NSString*)title;


- (id)initEmail:(UIViewController*)vCtrl_;
- (BOOL)sendEmailTitle:(NSString*)title body:(NSString*)message toaddr:(NSString*)toaddr;
- (BOOL)sendEmailTitle:(NSString*)title body:(NSString*)message toaddr:(NSString*)toaddr objs:(NSArray*)objs;
@end
